const winston = require('winston');
const loggerSetting = require('../../setting').logger;
require('winston-daily-rotate-file');
const { combine, timestamp, label, printf } = winston.format;
const myFormat = printf(({ level, message, label, timestamp }) => {
    return `${timestamp} [${label}] ${level}: ${message}`;
});
const logger = winston.createLogger({
    // format: winston.format.json(),
    // defaultMeta: { service: 'user-service' },
    format: combine(
        label({ label: 'logger' }),
        timestamp(),
        myFormat
    ),
    transports: [
        new winston.transports.Console(),
        new winston.transports.DailyRotateFile({ filename: `${loggerSetting.path}/error.log`, datePattern: "yyyy_MM_DD", level: 'error' }),
        new winston.transports.DailyRotateFile({ filename: `${loggerSetting.path}/info.log`, datePattern: "yyyy_MM_DD", level: 'info' }),
        new winston.transports.DailyRotateFile({ filename: `${loggerSetting.path}/combined.log`, datePattern: "yyyy_MM_DD", }),
    ],
});
module.exports = logger;